package com.cailu.rabmq.sender.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cailu.common.bean.UserReqBean;
import com.cailu.rabmq.sender.sender.DirectSenderTemplate;
import com.cailu.rabmq.sender.version.ApiVersionConstant;
import com.cailu.rabmq.sender.version.ApiVersions;

/**
 * @author cailu
 * @filename DirectSenderController
 * @description Direct 直接交换模式Controller
 * @date 2020/3/30 14:42
 */
@Api(value = "10001-Direct 直接交换模式", tags = { "10001-Direct 直接交换模式" })
@RestController
public class DirectSenderController {

	@Autowired
	private DirectSenderTemplate directSenderTemplate;

	/**
	 * 功能描述 创建 发布者 消息
	 * @return java.lang.String
	 * @author cailu
	 * @date 2020/3/30 16:23
	 */
	@GetMapping("sendHelloTemplate")
	@ApiOperation(value = "10001-创建普通发布者", notes = "创建普通发布者")
	@ApiVersions(group = ApiVersionConstant.FAP_APP100)
	public String sendHelloTemplate() {
		directSenderTemplate.sendHelloTemplate();
		return "创建指定发布者成功!";
	}

	/**
	 * 功能描述 自定义发送能容
	 * http://localhost:8683/sendTemplate?str=内容
	 * @param str 发送的内容
	 * @return java.lang.String
	 * @author cailu
	 * @date 2020/3/30 16:22
	 */
	@ApiOperation(value = "10002-创建自定义发布者", notes = "创建自定义发布者")
	@ApiVersions(group = ApiVersionConstant.FAP_APP100)
	@GetMapping("sendTemplate")
	public String sendTemplate(@ApiParam(value = "自定义发送能容") @RequestParam(value = "str") String str) {
		directSenderTemplate.sendTemplate(str);
		return "创建自定义发布者成功!";
	}

	/**
	 * 功能描述  创建对象发布者
	 * @return java.lang.String
	 * @author cailu
	 * @date 2020/4/1 13:47
	 */
	@ApiOperation(value = "10003-创建对象发布者", notes = "创建对象发布者")
	@ApiVersions(group = ApiVersionConstant.FAP_APP100)
	@GetMapping("sendUserVoTemplate")
	public String sendUserVoTemplate(@ModelAttribute UserReqBean userReq) {
		directSenderTemplate.sendUserVoTemplate(userReq);
		return "创建对象发布者成功!";
	}

}
